package com.controller;

import com.entity.AddressList;
import com.github.pagehelper.PageInfo;
import com.service.imp.AddressListServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class MyController {
    @Autowired
    private AddressListServiceImp addressListServiceImp;

    @RequestMapping("show")
    public String findAll(Model model,int pageNum){

        PageInfo<AddressList> page = addressListServiceImp.findAll(pageNum);
        List<AddressList> list = page.getList();
        model.addAttribute("page",page);
        model.addAttribute("list",list);
        return "show.jsp";
    }
    @RequestMapping("insert")
    public String insert(String A_Name,String A_Phone,String A_Mail,String A_Relation){
        addressListServiceImp.insert(A_Name,A_Phone,A_Mail,A_Relation);
        return "/show?pageNum=1";
    }
    @RequestMapping("delete")
    public String delete(int id){
        addressListServiceImp.delete(id);
        return "/show?pageNum=1";
    }
}
